package com.gxuwz.com_property.menu.service.impl;

import com.gxuwz.com_property.menu.mapper.MenuMapper;
import com.gxuwz.com_property.menu.pojo.Menu;
import com.gxuwz.com_property.menu.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class MenuServiceImpl implements MenuService {

    @Autowired
    private MenuMapper menuMapper;

    /**
     * 实现查询菜单列表
     *
     * @return*/
    @Override
    public List<Menu> SelectMenu(Menu menu) {
        try {
            List<Menu> menus = menuMapper.SelectMenu(menu);
            if (menus!=null){
                return menus;
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

    /**
     * 根据用户权限查询菜单
     * */
    @Override
    public List<Menu> findMenuByToken(Menu menu) {
        try {
            List<Menu> menus = menuMapper.findMenuByToken(menu);
            if (menus!=null){
                return menus;
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

    @Override
    public boolean updateMenu(Menu menu) {
        return menuMapper.updateMenu(menu);
    }

    @Override
    public boolean addMenu(Menu menu) {
        return menuMapper.addMenu(menu);
    }

    @Override
    public boolean delectMenu(int id) {
        return menuMapper.delectMenu(id);
    }
}
